﻿using System;
using System.Net;

using Kannon.Core;

using NUnit.Framework;

namespace Kannon.Tests.Core
{
    [TestFixture]
    public class KannonResponseTestFixture
    {
        [Test]
        public void ImplicitFromString()
        {
            const string HelloWorld = "Hello, world!";

            KannonResponse response = HelloWorld;

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.AreEqual("text/html; charset=utf-8", response.Headers["Content-Type"]);
            Assert.AreEqual(HelloWorld.Length.ToString(), response.Headers[HttpResponseHeader.ContentLength]);
        }

        [Test]
        public void ImplicitFromUri()
        {
            var location = new Uri("http://www.google.com/", UriKind.Absolute);

            KannonResponse response = location;

            Assert.AreEqual(HttpStatusCode.Found, response.StatusCode);
            Assert.AreEqual(location.ToString(), response.Headers[HttpResponseHeader.Location]);
        }

        [Test]
        public void ImplicitFromHttpStatusCode()
        {
            KannonResponse response = HttpStatusCode.ServiceUnavailable;

            Assert.AreEqual(HttpStatusCode.ServiceUnavailable, response.StatusCode);
        }
    }
}
